/*
 * 作者:熊猫
 * 日期:2017 - 3 - 20 4 - 29 - 8
 *
 */

package net.lainiao.morethread.Chapter8.demo5;

import java.io.IOException;
import java.util.logging.*;

/**
 * Created by Administrator on 2017/3/20.
 */
public class MyLogger  {
    private static Handler handler;
    public static Logger  getLogger(String name){
        Logger logger=Logger.getLogger(name);
        logger.setLevel(Level.ALL);
        try {
            if(handler==null){
                handler=new FileHandler("recipe8.log");
                Formatter formatter=new MyFormatter();
                handler.setFormatter(formatter);
            }

            if(logger.getHandlers().length==0){
                logger.addHandler(handler);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return logger;
    }
}
